package com.yang.concurrency.chapter7;

/**
 * @Author: 血魔
 * @Date: Created in 20:21 2021/12/12
 * @Version: $
 */
public class SynchronizedStatic {

    static {
        synchronized (SynchronizedStatic.class){
            try{
                System.out.println("static " + Thread.currentThread().getName());
                Thread.sleep(1000L);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public synchronized static void m1(){
        System.out.println("m1 " + Thread.currentThread().getName());
        try {
            Thread.sleep(10*1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized static void m2(){
        System.out.println("m1 " + Thread.currentThread().getName());
        try {
            Thread.sleep(10*1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void m3() {
        System.out.println("m3 "+Thread.currentThread().getName());
        try{
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
